package com.huo.com.redisLock.configredis;

import com.huo.com.redisLock.redislistener.MyListener;
import org.aspectj.lang.annotation.Before;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

@Configuration
public class TestRedisConfig {

   @Bean
   public RedisMessageListenerContainer getRedisMessageListener(RedisConnectionFactory redisConnectionFactory, MyListener myListener, MyListener myLgRedisListener){

       RedisMessageListenerContainer redisMessageListenerContainer=new RedisMessageListenerContainer();
       //添加队列的监听
       redisMessageListenerContainer.addMessageListener(myListener,new PatternTopic("LOCK"));
       redisMessageListenerContainer.addMessageListener(myLgRedisListener,new PatternTopic("LG"));

       redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory);

       return redisMessageListenerContainer;
   }

}
